<script type="text/javascript" >
    stFacebookToolbox.load_tooltip();
    stFacebookToolbox.on_submitform('#settingForm');
    function drawVisualization() {
  // Create and populate the data table.
  var data = new google.visualization.DataTable();
                data.addColumn('string', 'Day');
                data.addColumn('number', 'Likes');
                data.addColumn('number', 'Shares');
                data.addColumn('number', 'Comments');
                data.addColumn('number', 'Clicks');
                <?php  if(count($chart) > 0){ foreach($chart as $row): ?>
                data.addRow(["<?php echo $row['day'];?>", <?php echo $row['likes']; ?>,<?php echo $row['shares'];?>,<?php echo $row['comments'];?>,<?php echo $row['clicks'];?>]);
                <?php endforeach; }?>
  // Create and draw the visualization.
  new google.visualization.LineChart(document.getElementById('chart_div')).
      draw(data, {curveType: "function",
                  width: 950, height: 400,pointSize:4,
                  vAxis: {maxValue: 10}}
          );
}
</script>
<div class="w100p bgl">
    <div class="w100p bgr p5b">
                <ul class="menu_right">
                      <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_analytics');" id="Statistics">Statistics</a>
                    </li>
                    <li class="current">
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_daily_change&month=<?php echo date('m');?>&year=<?php echo date('Y');?>&site_id='+jQuery('#domain').val());" id="daily_change">Daily change</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_aggregated&month=<?php echo date('m');?>&year=<?php echo date('Y');?>&site_id='+jQuery('#domain').val());" id="aggregated">Aggregated</a>
                    </li>
                </ul>
         &nbsp;&nbsp;&nbsp;&nbsp;Filter by sitemap:
        <select name="domain" id="domain" style="margin-bottom:10px;margin-left:10px;" onchange="stFacebookToolboxcustom.loadPage('like_daily_change&site_id='+this.value+'&month='+jQuery('#month').val()+'&year='+jQuery('#year').val())">
            <option value="all">all</option>
            <?php foreach($sitemap as $site):?>
            <option value="<?php echo $site->id;?>" <?php if($site_id == $site->id){echo 'selected';} ?>><?php echo $site->site_name;?></option>
            <?php endforeach;?>

        </select>
        <div id="chart_div" style="height: 400px;" align="center" ><center><br><br><br><br><br><br><br><br><br><br>NO DATA</center></div>
        <div id="date_control" align="center"><img onclick="stFacebookToolboxcustom.prev_month('like_daily_change&site_id='+jQuery('#domain').val());" style="cursor: pointer;" src="<?php echo $plugin_url;?>images/arrow_left.png">&nbsp;<span id="month_year"><?php echo $month_name[intval($month)].'&nbsp;'.$year;?></span>&nbsp;<img onclick="stFacebookToolboxcustom.next_month('like_daily_change&site_id='+jQuery('#domain').val());" style="cursor: pointer;" src="<?php echo $plugin_url;?>/images/arrow_right.png"></div>
        <input type="hidden" id="check_chart" value="<?php if(count($chart) > 0){echo '1';}else{echo '0';}?>" />
        <input type="hidden" id="month" value="<?php echo $month;?>" />
        <input type="hidden" id="year" value="<?php echo $year;?>" />
                        <p></p>
		<table cellspacing="0" class="widefat" align="center">
                <thead>
                    <tr>
                        	<th style="" class="manage-column column-uid" id="date" scope="col">Date</th>
							<th style="" class="manage-column column-firstname" id="likes" scope="col">	Number of likes</th>
							<th style="" class="manage-column column-lastname" id="shares" scope="col">Number of Shares</th>
							<th style="" class="manage-column column-sex" id="comments" scope="col">Number of comments</th>
							<th style="" class="manage-column column-locale" id="clicks" scope="col">	Number of clicks</th>

                    </tr>
                </thead>
				<?php if(count($chart) > 0):?>
                <tbody>
                <?php $chart = array_reverse($chart);$stt = 1;foreach($chart as $row): ?>
                <tr class="bg_gray<?php echo (($stt % 2) == 0)?'1':'2'?>" id="<?php echo $row['day'];?>">
                <td>
                <?php echo $row['day'];?>
				</td>
				<td><?php echo $row['likes'];?></td>
				<td><?php echo $row['shares'];?></td>
				<td><?php echo $row['comments'];?></td>
				<td><?php echo $row['clicks'];?></td>
				</tr>
				<?php $stt++; endforeach;?>
				</tbody>
				<?php endif;?>
            </table>
    </div>
</div>
